1. Field of the Invention
The present invention relates generally to autofocus camera, and more particularly, to an autofocus method that processes data of lens positions and focus values so as to obtain a lens position at which a sharp image can be captured. The present invention further relates to an autofocus system that is capable of fast estimating an in-focus position.
2. Description of Related Art
In the autofocus process of a camera, the lens of the camera is moved from one position to another. At each lens position, the corresponding focus value is calculated. After each movement of the lens, a decision is made as to whether the maximum focus value is obtained.
FIG. 1A is a diagram illustrating the relationship between focus values and lens positions. The peak point H shown in FIG. 1A corresponds to the maximum focus value. FIG. 1B shows a conventional autofocus process. The autofocus process continues until the maximum focus value is found, at which a focused image can be captured. That is, if the ideal lens position is found, the autofocus process terminates; otherwise, the direction and distance of the subsequent movement of the lens are determined, and the steps of moving the lens and calculating the focus value are repeated.
Various algorithms, such as global search, binary search, and rules-based search algorithms, can be applied to search for the lens position that gives rise to maximum focus value.
The global search algorithm records the focus value at each lens movement and goes through all lens positions to exhaustively determine which lens position gives rise to the maximum focus value. Therefore, a reasonably complete plot close to that shown in FIG. 1A is obtained, and the peak point H can be accurately identified. However, the global search algorithm is time consuming.
To overcome the above-described drawback, a two-stage search algorithm has been developed, wherein the search process comprises a coarse search stage and a fine search stage. The coarse search is first performed according to the gradient of the focus values with respect to the lens position so as to estimate which range the peak point H may fall within. Subsequently, a fine search is performed by fitting a second-order quadratic or Gaussian curve to the focus values as a function of lens position within the range of the peak point described above.
Furthermore, U.S. Publication No. 2008/0180563 discloses another autofocus method, wherein a search step look-up table is established in accordance with the total number of lens movements and the corresponding focus values. During the autofocus process, the direction and the distance of lens movements are determined in accordance with the search step look-up table.
Compared with the global search algorithm, the above-described techniques can increase the speed and reduce the number of lens movements. However, all these techniques require parameter adjustment and may not be efficient enough for practical applications. In addition, these techniques may not be able to provide sufficiently accurate results.
The autofocus of a camera primarily includes two parts: focus measurement and search strategy. The focus measurement generates an associated focus value according to an input image, and a focus profile (or focus curve) may thus be obtained by collecting lens positions and their associated focus values. The search strategy obtains an in-focus position, that is, a lens position with a maximum focus value, by moving the lens according to the obtained focus profile.
Conventional search strategies generally have the following drawbacks. The focus profile usually has steep and narrow curvature around the maximum focus value for the purpose of resisting noise in an image to improve accuracy of the autofocus. The steep-and-narrow focus profile reduces the search speed, or makes it difficult for the conventional search strategies to design. Moreover, the conventional search strategies commonly use a lot of parameters to locate a current lens position along the focus profile. It is not only difficult to determine the parameters but also hard to apply the parameters to different scenes with distinct complexities. For the worse, the parameters need be determined again once the focus measurement is replaced. Furthermore, a rule-based search strategy, such as Fibonacci search strategy, cannot be well adapted to the autofocus of a digital video camera for the reason that some assumptions about an initial lens position should be made.
Accordingly, a need has thus arisen to provide a novel autofocus scheme to solve the problems related to the conventional autofocus methods.